using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace gngui
{
    enum DObjectType
    {
        DObjectType_Uniform,
        DObjectType_Zipf
    };

    enum DEdgeType
    {
        DEdgeType_TG,
        DEdgeType_OL
    };

    enum SearchType
    {
        SearchType_NDMR,
        SearchType_EDMR
    };

    enum CommandType
    {
        COMMAND_SCROLL_UP,
        COMMAND_SCROLL_DOWN,
        COMMAND_SCROLL_LEFT,
        COMMAND_SCROLL_RIGHT,
        COMMAND_ZOOM_IN,
        COMMAND_ZOOM_OUT,
        COMMAND_DEMO_START,
        COMMAND_DEMO_END,
        COMMAND_DEMO_MOVE
    };

    [StructLayout(LayoutKind.Sequential)] 
    struct SplitNodeInfo
    {
        public int iObjID;
        public int iPosX;
        public int iPosY;
    }

    [StructLayout(LayoutKind.Sequential)] 
    struct ObjectInfo
    {
        public int iObjID;
        public int iPosX;
        public int iPosY;
    }

    class ServiceWrapper
    {
        [DllImport("Service.dll", EntryPoint = "Initialize")]
        static public extern int Initialize(IntPtr hwnd, int iWidth, int iHeight);

        [DllImport("Service.dll", EntryPoint = "UnInitialize")]
        static public extern int UnInitialize();

        [DllImport("Service.dll", EntryPoint = "GenerateData")]
        static public extern int GenerateData(string pcDataPath, DObjectType dObj, int iObjectCnt);

        [DllImport("Service.dll", EntryPoint = "LoadData")]
        static public extern int LoadData(string pcDataPath, ref int hMapData);

        [DllImport("Service.dll", EntryPoint = "UnloadData")]
        static public extern int UnloadData(int hMapData);

        [DllImport("Service.dll", EntryPoint = "CalcRouteInfo")]
        static public extern int CalcRouteInfo(int hMapData, SearchType schType, float fRadius, int iL, float fThiter, int iSpeed, float fAmbig);

        [DllImport("Service.dll", EntryPoint = "ExecuteCommand")]
        static public extern int ExecuteCommand(CommandType cmd);
 
        [DllImport("Service.dll", EntryPoint = "DoRender")]
        static public extern int DoRender(ref byte pvBuff);

        [DllImport("Service.dll", EntryPoint = "ReleaseRouteInfo")]
        static public extern int ReleaseRouteInfo(int hMapData);

        [DllImport("Service.dll", EntryPoint = "GetObjectCnt")]
        static public extern int GetObjectCnt(ref int piCnt);

        [DllImport("Service.dll", EntryPoint = "GetObjectPosition")]
        static public extern int GetObjectPosition(ref ObjectInfo pstObjInfo);

        [DllImport("Service.dll", EntryPoint = "GetSplitNodeCnt")]
        static public extern int GetSplitNodeCnt(ref int piSnCnt);

        [DllImport("Service.dll", EntryPoint = "GetSearchObjCnt")]
        static public extern int GetSearchObjCnt(ref int piObjCnt);

        [DllImport("Service.dll", EntryPoint = "GetSplitNodeInfo")]
        static public extern int GetSplitNodeInfo(ref SplitNodeInfo pstSnInfo);

        [DllImport("Service.dll", EntryPoint = "GetSearchObjInfo")]
        static public extern int GetSearchObjInfo(ref ObjectInfo pstObjInfo);

        [DllImport("Service.dll", EntryPoint = "GetMapCenterPoint")]
        static public extern int GetMapCenterPoint(ref float fCenterX, ref float fCenterY);

        [DllImport("Service.dll", EntryPoint = "GetMapScale")]
        static public extern int GetMapScale(ref float fScale);
    }

    class NoFilpPanel:System.Windows.Forms.Panel
    {
        public NoFilpPanel()
        {
            this.DoubleBuffered = true;
        }
    }
}
